package com.deyuanyun.pic.ctrl.controller.dto;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.poi.annotation.ExcelWriteColumn;
import com.deyuanyun.pic.ctrl.enumeration.InfluencePositionEnum;
import com.deyuanyun.pic.ctrl.mapper.EqptCptestStationMapper;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Description 高压交流输电系统干扰源展示dto
 * @author Jerry
 * @date 2016-09-07
 */
public class InfluenceHtacDTO {
    /**
     * 主键
     */
    private String id;

    /**
     * 创建时间
     */
    private Date createDate;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 创建备注
     */
    private String createRemark;

    /**
     * 更新时间
     */
    private Date updateDate;

    /**
     * 更新人员
     */
    private String updateUser;

    /**
     * 更新原因
     */
    private String updateRemark;

    /**
     * 逻辑删除字段
     */
    private Short deleted;

    /**
     * 版本
     */
    private Short version;

    /**
     * 是否是最新数据，0：最新数据；1：历史数据
     */
    private Short isNewest;

    /**
     * 数据状态
     */
    private String dataStated;

    /**
     * 管道
     */
    private String pipeLineId;

    /**
     * 所属管道
     */
    @ExcelWriteColumn
    private String pipeName;

    /**
     * 统一编号
     */
    private String code;

    /**
     * 设备编号(自定义编号)
     */
    @ExcelWriteColumn
    private String customNumber;

    /**
     * 干扰源名称
     */
    @ExcelWriteColumn
    private String name;

    /**
     * 相对位置关系(平行PARALLEL、交叉ACROSS)
     */
    @ExcelWriteColumn
    private String relativePositionRelation;

    /**
     * GISID
     */
    private String gisid;

    /**
     * 平行段起点_绝对里程
     */
    @ExcelWriteColumn
    private String beginMileage;

    /**
     * 平行起点_附近测试桩
     */
    private String beginNagm;

    @ExcelWriteColumn
    private String pbeginNgm;

    /**
     * 平行起点_附近测试桩距离
     */
    @ExcelWriteColumn
    private String beginNagmMileage;

    /**
     * 平行段终点_绝对里程
     */
    @ExcelWriteColumn
    private String endMileage;

    /**
     * 平行段终点_附近测试桩
     */

    private String endNagm;

    @ExcelWriteColumn
    private String pendNgm;

    /**
     * 平行段终点_附近测试桩距离
     */
    @ExcelWriteColumn
    private String endNagmMileage;

    /**
     * 最小平行间距
     （m）
     */
    @ExcelWriteColumn
    private BigDecimal minDistance;

    /**
     * 平行长度
     */
    @ExcelWriteColumn
    private  BigDecimal parallelMileage;

    /**
     * 交叉段_绝对里程
     */
    @ExcelWriteColumn
    private String crossMileage;

    /**
     * 交叉段_附近测试桩
     */
    private String crossNagm;

    @ExcelWriteColumn
    private String crossNgm;

    /**
     * 交叉段_附近测试桩距离
     */
    @ExcelWriteColumn
    private String crossNagmMileage;

    /**
     * 位置描述
     */
    @ExcelWriteColumn
    private String locationDescription;

    /**
     * 导线类型
     */
    @ExcelWriteColumn
    private String conductorType;

    /**
     * 平均对地高度（m）
     */
    @ExcelWriteColumn
    private BigDecimal avgHeightOfTheGround;

    /**
     * 额定电压（V）
     */
    @ExcelWriteColumn
    public Long ratedVolts;

    /**
     * 负载电流(A)
     */
    @ExcelWriteColumn
    public Long loadcurrent;

    /**
     * 三相载荷不平衡度
     */
    @ExcelWriteColumn
    private String threePhaseUnbalancedLoad;

    /**
     * 单相短路故障电流(A)
     */
    @ExcelWriteColumn
    public Long shortCircuitFaultCurrent;

    /**
     * 故障持续时间(h)
     */
    @ExcelWriteColumn
    public Long faultDuration;

    /**
     * 接地体与管道最小距离（m）
     */
    @ExcelWriteColumn
    private BigDecimal groundMinDistance;

    /**
     * 区域内发电厂设置情况记录
     */
    @ExcelWriteColumn
    private String powerPlant;

    /**
     * 检测日期
     */
    @ExcelWriteColumn
    private Date testingDate;


    /**
     * 检测单位
     */
    @ExcelWriteColumn
    private String testingCompany;


    /**
     * 记录人（直接存名称）
     */
    @ExcelWriteColumn
    private String recorder;

    /**
     * 记录时间
     */
    @ExcelWriteColumn
    private Date recordTime;

    /**
     * 备注
     */
    @ExcelWriteColumn
    private String remarks;

    /**
     * 业务组织路径
     */
    private String orgBizPath;

    /**
     *管道gisid
     */
    private String pipeGisId;


    /**
     * @return 主键
     */
    public String getId() {
        return id;
    }

    /**
     * @param id
     *            主键
     */
    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    /**
     * @return 创建时间
     */
    public Date getCreateDate() {
        return createDate;
    }

    /**
     * @param createDate
     *            创建时间
     */
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    /**
     * @return 创建人
     */
    public String getCreateUser() {
        return createUser;
    }

    /**
     * @param createUser
     *            创建人
     */
    public void setCreateUser(String createUser) {
        this.createUser = createUser == null ? null : createUser.trim();
    }

    /**
     * @return 创建备注
     */
    public String getCreateRemark() {
        return createRemark;
    }

    /**
     * @param createRemark
     *            创建备注
     */
    public void setCreateRemark(String createRemark) {
        this.createRemark = createRemark == null ? null : createRemark.trim();
    }

    /**
     * @return 更新时间
     */
    public Date getUpdateDate() {
        return updateDate;
    }

    /**
     * @param updateDate
     *            更新时间
     */
    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    /**
     * @return 更新人员
     */
    public String getUpdateUser() {
        return updateUser;
    }

    /**
     * @param updateUser
     *            更新人员
     */
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser == null ? null : updateUser.trim();
    }

    /**
     * @return 更新原因
     */
    public String getUpdateRemark() {
        return updateRemark;
    }

    /**
     * @param updateRemark
     *            更新原因
     */
    public void setUpdateRemark(String updateRemark) {
        this.updateRemark = updateRemark == null ? null : updateRemark.trim();
    }

    /**
     * @return 逻辑删除字段
     */
    public Short getDeleted() {
        return deleted;
    }

    /**
     * @param deleted
     *            逻辑删除字段
     */
    public void setDeleted(Short deleted) {
        this.deleted = deleted;
    }

    /**
     * @return 版本
     */
    public Short getVersion() {
        return version;
    }

    /**
     * @param version
     *            版本
     */
    public void setVersion(Short version) {
        this.version = version;
    }

    /**
     * @return 是否是最新数据，0：最新数据；1：历史数据
     */
    public Short getIsNewest() {
        return isNewest;
    }

    /**
     * @param isNewest
     *            是否是最新数据，0：最新数据；1：历史数据
     */
    public void setIsNewest(Short isNewest) {
        this.isNewest = isNewest;
    }

    /**
     * @return 数据状态
     */
    public String getDataStated() {
        return dataStated;
    }

    /**
     * @param dataStated
     *            数据状态
     */
    public void setDataStated(String dataStated) {
        this.dataStated = dataStated == null ? null : dataStated.trim();
    }

    public String getPipeName() {
        return pipeName;
    }

    public void setPipeName(String pipeName) {
        this.pipeName = pipeName == null ? null : pipeName.trim();
    }


    /**
     * @return 所属管道
     */
    public String getPipeLineId() {
        return pipeLineId;
    }

    /**
     * @param pipeLineId
     *          所属管道
     */
    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId == null ? null : pipeLineId.trim();
    }

    /**
     * @return 统一编号
     */
    public String getCode() {
        return code;
    }

    /**
     * @param code
     *            统一编号
     */
    public void setCode(String code) {
        this.code = code == null ? null : code.trim();
    }

    /**
     * @return 设备编号(自定义编号)
     */
    public String getCustomNumber() {
        return customNumber;
    }

    /**
     * @param customNumber
     *            设备编号(自定义编号)
     */
    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber == null ? null : customNumber.trim();
    }

    /**
     * @return 干扰源名称
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     *            干扰源名称
     */
    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    /**
     * @return 相对位置关系(平行PARALLEL、交叉ACROSS)
     */
    public String getRelativePositionRelation() {

        if(InfluencePositionEnum.PARALLEL.toString().equals(this.relativePositionRelation)){
            return "平行";
        }else if(InfluencePositionEnum.ACROSS.toString().equals(this.relativePositionRelation)){
            return "交叉";
        }
        return null;
    }

    /**
     * @param relativePositionRelation
     *            相对位置关系(平行PARALLEL、交叉ACROSS)
     */
    public void setRelativePositionRelation(String relativePositionRelation) {
        this.relativePositionRelation = relativePositionRelation == null ? null : relativePositionRelation.trim();
    }

    /**
     * @return GISID
     */
    public String getGisid() {
        return gisid;
    }

    /**
     * @param gisid
     *            GISID
     */
    public void setGisid(String gisid) {
        this.gisid = gisid == null ? null : gisid.trim();
    }

    /**
     * @return 平行段起点_绝对里程
     */
    public String  getBeginMileage() {

        return transformNum(beginMileage);
    }

    /**
     * @param beginMileage
     *            平行段起点_绝对里程
     */
    public void setBeginMileage(String beginMileage) {
        this.beginMileage = beginMileage;
    }

    /**
     * @return 平行起点_附近测试桩
     */
    public String getBeginNagm() {

        return beginNagm;
    }

    /**
     * @param beginNagm
     *            平行起点_附近测试桩
     */
    public void setBeginNagm(String beginNagm) {
        this.beginNagm = beginNagm == null ? null : beginNagm.trim();
    }

    /**
     * @return 平行起点_附近测试桩距离
     */
    public String getBeginNagmMileage() {

        return transformNum(beginNagmMileage);
    }

    /**
     * @param beginNagmMileage
     *            平行起点_附近测试桩距离
     */
    public void setBeginNagmMileage(String beginNagmMileage) {
        this.beginNagmMileage = beginNagmMileage;
    }

    /**
     * @return 平行段终点_绝对里程
     */
    public String getEndMileage() {
        return transformNum(endMileage);
    }

    /**
     * @param endMileage
     *            平行段终点_绝对里程
     */
    public void setEndMileage(String endMileage) {
        this.endMileage = endMileage;
    }

    /**
     * @return 平行段终点_附近测试桩
     */
    public String getEndNagm() {

        return endNagm;
    }

    /**
     * @param endNagm
     *            平行段终点_附近测试桩
     */
    public void setEndNagm(String endNagm) {
        this.endNagm = endNagm == null ? null : endNagm.trim();
    }

    /**
     * @return 平行段终点_附近测试桩距离
     */
    public String getEndNagmMileage() {

        return transformNum(endNagmMileage);
    }

    /**
     * @param endNagmMileage
     *            平行段终点_附近测试桩距离
     */
    public void setEndNagmMileage(String endNagmMileage) {
        this.endNagmMileage = endNagmMileage;
    }

    /**
     * @return 最小平行间距
    （m）
     */
    public BigDecimal getMinDistance() {
        return minDistance;
    }

    /**
     * @param minDistance
     *            最小平行间距
    （m）
     */
    public void setMinDistance(BigDecimal minDistance) {
        this.minDistance = minDistance;
    }

    /**
     * 系统计算平行长度 （终点距离-起点距离）
     * @return
     */
    public BigDecimal getParallelMileage() {
        if(this.beginMileage != null && this.endMileage !=null){
            return parallelMileage =new BigDecimal(Long.parseLong(this.endMileage)-Long.parseLong(this.beginMileage)).
                    divide(new BigDecimal(1000)).setScale(3,BigDecimal.ROUND_DOWN) ;
        }else{
            return null;
        }
    }

    public void setParallelMileage(BigDecimal parallelMileage) {
        this.parallelMileage = parallelMileage;
    }

    /**
     * @return 交叉段_绝对里程
     */
    public String getCrossMileage() {

        return transformNum(crossMileage);
    }

    /**
     * @param crossMileage
     *            交叉段_绝对里程
     */
    public void setCrossMileage(String crossMileage) {
        this.crossMileage = crossMileage;
    }

    /**
     * @return 交叉段_附近测试桩
     */
    public String getCrossNagm() {

        return crossNagm;
    }

    /**
     * @param crossNagm
     *            交叉段_附近测试桩
     */
    public void setCrossNagm(String crossNagm) {
        this.crossNagm = crossNagm == null ? null : crossNagm.trim();
    }

    /**
     * @return 交叉段_附近测试桩距离
     */
    public String getCrossNagmMileage() {

        return transformNum(crossNagmMileage);
    }

    /**
     * @param crossNagmMileage
     *            交叉段_附近测试桩距离
     */
    public void setCrossNagmMileage(String crossNagmMileage) {
        this.crossNagmMileage = crossNagmMileage;
    }

    /**
     * @return 位置描述
     */
    public String getLocationDescription() {
        return locationDescription;
    }

    /**
     * @param locationDescription
     *            位置描述
     */
    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription == null ? null : locationDescription.trim();
    }

    /**
     * @return 导线类型
     */
    public String getConductorType() {
        return conductorType;
    }

    /**
     * @param conductorType
     *            导线类型
     */
    public void setConductorType(String conductorType) {
        this.conductorType = conductorType == null ? null : conductorType.trim();
    }

    /**
     * @return 平均对地高度（m）
     */
    public BigDecimal getAvgHeightOfTheGround() {
        return avgHeightOfTheGround;
    }

    /**
     * @param avgHeightOfTheGround
     *            平均对地高度（m）
     */
    public void setAvgHeightOfTheGround(BigDecimal avgHeightOfTheGround) {
        this.avgHeightOfTheGround = avgHeightOfTheGround;
    }

    /**
     * @return 额定电压（V）
     */
    public Long getRatedVolts() {
        return ratedVolts;
    }

    /**
     * @param ratedVolts
     *            额定电压（V）
     */
    public void setRatedVolts(Long ratedVolts) {
        this.ratedVolts = ratedVolts;
    }

    /**
     * @return 负载电流(A)
     */
    public Long getLoadcurrent() {
        return loadcurrent;
    }

    /**
     * @param loadcurrent
     *            负载电流(A)
     */
    public void setLoadcurrent(Long loadcurrent) {
        this.loadcurrent = loadcurrent;
    }

    /**
     * @return 三相载荷不平衡度
     */
    public String getThreePhaseUnbalancedLoad() {
        return threePhaseUnbalancedLoad;
    }

    /**
     * @param threePhaseUnbalancedLoad
     *            三相载荷不平衡度
     */
    public void setThreePhaseUnbalancedLoad(String threePhaseUnbalancedLoad) {
        this.threePhaseUnbalancedLoad = threePhaseUnbalancedLoad == null ? null : threePhaseUnbalancedLoad.trim();
    }

    /**
     * @return 单相短路故障电流(A)
     */
    public Long getShortCircuitFaultCurrent() {
        return shortCircuitFaultCurrent;
    }

    /**
     * @param shortCircuitFaultCurrent
     *            单相短路故障电流(A)
     */
    public void setShortCircuitFaultCurrent(Long shortCircuitFaultCurrent) {
        this.shortCircuitFaultCurrent = shortCircuitFaultCurrent;
    }

    /**
     * @return 故障持续时间(h)
     */
    public Long getFaultDuration() {
        return faultDuration;
    }

    /**
     * @param faultDuration
     *            故障持续时间(h)
     */
    public void setFaultDuration(Long faultDuration) {
        this.faultDuration = faultDuration;
    }

    /**
     * @return 接地体与管道最小距离（m）
     */
    public BigDecimal getGroundMinDistance() {
        return groundMinDistance;
    }

    /**
     * @param groundMinDistance
     *            接地体与管道最小距离（m）
     */
    public void setGroundMinDistance(BigDecimal groundMinDistance) {
        this.groundMinDistance = groundMinDistance;
    }

    /**
     * @return 区域内发电厂设置情况记录
     */
    public String getPowerPlant() {
        return powerPlant;
    }

    /**
     * @param powerPlant
     *            区域内发电厂设置情况记录
     */
    public void setPowerPlant(String powerPlant) {
        this.powerPlant = powerPlant == null ? null : powerPlant.trim();
    }

    /**
     * @return 检测单位
     */
    public String getTestingCompany() {
        return testingCompany;
    }

    /**
     * @param testingCompany
     *            检测单位
     */
    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany == null ? null : testingCompany.trim();
    }

    /**
     * @return 检测日期
     */
    public Date getTestingDate() {
        return testingDate;
    }

    /**
     * @param testingDate
     *            检测日期
     */
    public void setTestingDate(Date testingDate) {
        this.testingDate = testingDate;
    }

    /**
     * @return 记录人（直接存名称）
     */
    public String getRecorder() {
        return recorder;
    }

    /**
     * @param recorder
     *            记录人（直接存名称）
     */
    public void setRecorder(String recorder) {
        this.recorder = recorder == null ? null : recorder.trim();
    }

    /**
     * @return 记录时间
     */
    public Date getRecordTime() {
//      if(this.recordTime!=null){
//          return recordTime;
//      }else{
//          return recordTime = new Date();
//      }
        return  recordTime;
    }

    /**
     * @param recordTime
     *            记录时间
     */
    public void setRecordTime(Date recordTime) {
        this.recordTime = recordTime;
    }

    /**
     * @return 备注
     */
    public String getRemarks() {
        return remarks;
    }

    /**
     * @param remarks
     *            备注
     */
    public void setRemarks(String remarks) {
        this.remarks = remarks == null ? null : remarks.trim();
    }

    /**
     * @return 业务组织路径
     */
    public String getOrgBizPath() {
        return orgBizPath;
    }

    /**
     * @param orgBizPath
     *            业务组织路径
     */
    public void setOrgBizPath(String orgBizPath) {
        this.orgBizPath = orgBizPath == null ? null : orgBizPath.trim();
    }

    public String getPipeGisId() {
        return pipeGisId;
    }

    public void setPipeGisId(String pipeGisId) {
        this.pipeGisId = pipeGisId;
    }

    public String getPbeginNgm() {
        return pbeginNgm;
    }

    public void setPbeginNgm(String pbeginNgm) {
        this.pbeginNgm = pbeginNgm;
    }

    public String getPendNgm() {
        return pendNgm;
    }

    public void setPendNgm(String pendNgm) {
        this.pendNgm = pendNgm;
    }

    public String getCrossNgm() {
        return crossNgm;
    }

    public void setCrossNgm(String crossNgm) {
        this.crossNgm = crossNgm;
    }

    /**
     * 用string处理数据保持精度的正确（转化为3位小数）
     * @param mileage
     * @return
     */
    private  String transformNum(String mileage){
        if(mileage!=null){
            return new BigDecimal(mileage).divide(new BigDecimal(1000)).setScale(3,BigDecimal.ROUND_DOWN).stripTrailingZeros().toPlainString();
        }else{
            return null;
        }
    }

    /**
     *  得到阴保测试桩基础信息表里的customnumber
     * @param id 干扰源对应的测试桩编号
     * @return
     */
//    private String getCustom(String id){
//        if(ObjectUtil.isNotNullEmpty( eqptCptestStationMapper.selectByPrimaryKey(id))){
//            return  eqptCptestStationMapper.selectByPrimaryKey(id).getCustomNumber();
//        }
//        return null;
//    }
}
